package com.demo.controller;

import java.util.HashMap;
import java.util.Map;

public class BaseController {
    private Map<String,Object> getResult(int code,String msg,Object data){
        Map<String,Object> map = new HashMap<>();
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        return map;
    }

    public Map<String,Object> ok(Object data){
        return this.getResult(200,null,data);
    }

    public Map<String,Object> ok(){
        return this.getResult(200,null,null);
    }

    public Map<String,Object> fail(int code,String msg,Object data){
        return this.getResult(code,msg,data);
    }

    public Map<String,Object> fail(int code,String msg){
        return this.getResult(code,msg,null);
    }
}
